function [logL_neg]=likelihood_obj(parameter,ability_metric,LowCost_Ability,HighCost_Ability,age_l,age_h,V_l,V_h,outcome,tpORtp3h,Cpm25,parameter_fixed)


N=size(LowCost_Ability,1);

% Parameters that are estimated 
k         =parameter(1);
rho_ageHet=parameter(7);

% Conditions on age for which rho_ageHet is multiplied to contest prize; note that direct and indirect calls to transition_prob_oneshot, transition_prob_stage2, and transition_prob_stage1 start from likelihood_obj    
ageHet_l = (age_l>27.2);
ageHet_h = (age_h>27.2);
V_l = V_l.*(ageHet_l==0) + rho_ageHet*V_l.*(ageHet_l==1);
V_h = V_h.*(ageHet_h==0) + rho_ageHet*V_h.*(ageHet_h==1);


% Marginal cost (mc) function:
% inputs: ability metric, cost parameter, LowCost_Ability, HighCost_Ability
% outputs: c_l, c_h
[c_l,c_h]=mc(ability_metric,parameter,LowCost_Ability,HighCost_Ability);

% transition_prob_oneshot:
% inputs: c_l, c_h, V_l, V_h, k
% outputs: p_l_winoneshot=p_l_win3, p_h_winoneshot=p_h_win3
[p_lwin3,p_llose3]=transition_prob_oneshot(c_l,c_h,V_l,V_h,k);

% transition_prob_stage2:
% inputs: c_l, c_h, V_l, V_h, temperature, PM2.5, k, parameters of the delta function, calls on transition_prob_oneshot
% outputs: Continuation values (in stage 3) conditional on stage-2 outcome (and stage-1 history), stage-2 transition probabilities  
[~,~,~,~,~,~,~,~,p_lwin2_lwon1,p_llose2_lwon1,p_lwin2_llost1,p_llose2_llost1]=transition_prob_stage2(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h,age_l,age_h);

% transition_prob_stage1:
% inputs: c_l, c_h, V_l, V_h, temperature, PM2.5, k, parameters of the delta function, calls on transition_prob_stage2
% outputs: Continuation values (in stage 2) conditional on stage-1 outcome, stage-1 transition probabilities   
[~,~,~,~,p_lwin1,p_llose1]=transition_prob_stage1(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h,age_l,age_h);



% Compute probabilities for each match outcome (this can be sped up if necessary subsequently; e.g., for simulated likelihood)
prob_ll =p_lwin1 .*  p_lwin2_lwon1;
prob_lhl=p_lwin1 .* p_llose2_lwon1.* p_lwin3;
prob_lhh=p_lwin1 .* p_llose2_lwon1.*p_llose3;
prob_hll=p_llose1.* p_lwin2_llost1.* p_lwin3;
prob_hlh=p_llose1.* p_lwin2_llost1.*p_llose3;
prob_hh =p_llose1.*p_llose2_llost1;
prob=[prob_ll prob_lhl prob_lhh prob_hll prob_hlh prob_hh];
likelihood_contribution=sum(prob.*outcome,2);


logL_neg=-ones(1,N)*log(likelihood_contribution);
    

end